function manager = cm_create(capacity)
    block_template = struct('start', [], 'size', [], 'buf_id', []);
    manager.capacity = capacity;
    manager.allocated_blocks = repmat(block_template, 0, 1);
    if capacity > 0
        manager.free_blocks = struct('start', 0, 'size', capacity, 'buf_id', -1);
    else
        manager.free_blocks = repmat(block_template, 0, 1);
    end
end

